h2. Form Generator

There's a Formtastic form code generator to make your transition to Formtastic easier. All you have to do is to *specify an existing model name*, and optionally specify view template framework (ERB/HAML), and you are good to go. *Note:* This won't overwrite any of your stuff. This is how you use it:

*Alt. 1: Generate in terminal:*

<pre>
$ ./script/generate form Post
# ---------------------------------------------------------
#  GENERATED FORMTASTIC CODE
# ---------------------------------------------------------

<% f.inputs do %>
  <%= f.input :title, :label => 'Title' %>
  <%= f.input :body, :label => 'Body' %>
  <%= f.input :published, :label => 'Published' %>
<% end %>

# ---------------------------------------------------------
 Copied to clipboard - just paste it!
</pre>

In rails 3:

<pre>
rails g formtastic:form Post
</pre>

*Alt. 2: Generate partial:*

<pre>
$ ./script/generate form Post --partial
      exists  app/views/posts
      create  app/views/posts/_form.html.erb
</pre>

To generate *HAML* markup, just add the @--haml@ as argument:

<pre>
$ ./script/generate form Post --haml
      exists  app/views/admin/posts
      create  app/views/admin/posts/_form.html.haml
</pre>

To specify the controller in a namespace (eg admin/posts instead of posts), use the --controller argument:

<pre>
$ ./script/generate form Post --partial --controller admin/posts
      exists  app/views/admin/posts
      create  app/views/admin/posts/_form.html.erb
</pre>
